home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
X11
/
cpicker
/
Cpick.doc
< prev
next >
Wrap
Text File
|
1995-06-22
|
3KB
|
90 lines
/*
* Cpick.c - Color picker widget for X11 Toolkit
*
* Author: Mike Yang
* Western Research Laboratory
* Digital Equipment Corporation
* Date: Mon Aug 9 1988
* Copyright (c) 1988 Mike Yang
*/
The Cpick color picker widget prompts the user for an RGB color
selection. The various methods of selection are as follows:
1. Specify RGB, HSV, or CMY values through the use of sliders (Slide
widgets)
2. Choose a color from a palette covering the entire spectrum range
3. Choose a color from a palette covering a wide range about the
current color
4. Choose a color from a palette covering a narrow range about the
current color
5. (Not yet implemented) Specify RGB values by entering a hex string
The Cpick widget consists of:
1. nine labeled sliders for the current RGB, HSV, and CMY values,
2. a box displaying the current color selection,
3. a label showing the RGB values in hex notation,
4. a group of color cells from the current palette,
5. a button for changing the current palette, and
6. up to five buttons for interaction with the application (by
default these are "select," "cancel," "restore," "ok," and
"help."
The class variable for the Cpick color picker widget is
cpickWidgetClass.
When creating a Cpick widget instance, the following resources are
retrieved from the argument list or from the resource database (in
addition to the common resources):
Name Type Default Description
XtNselectProc XtCallBackList NULL Callback for select button
XtNokProc XtCallBackList NULL Callback for ok button
XtNchangeProc XtCallBackList NULL Callback for value change
XtNrestoreProc XtCallBackList NULL Callback for restore button
XtNallocated XColor* NULL Allocated cmap cell
XtNcmap Colormap NULL Colormap of allocated cell
XtNselectLabel char* "Select" Label for select button
XtNcancelLabel char* "Cancel" Label for cancel button
XtNrestoreLabel char* "Restore" Label for restore button
XtNokLabel char* "OK" Label for ok button
XtNhelpLabel char* "Help" Label for help button
XtNnearPixels int 64 Number of cells in palette
XtNuseColors Boolean FALSE Use colors in sliders?
To create a Cpick widget instance, use XtCreateWidget and specify the
class variable cpickWidgetClass.
It is important that you set XtNallocated to the allocated colormap
cell which the Cpick widget will use to display the current selection.
The callback procedures are called with the address of the XColor
structure. For instance, the callback procedure for the select button
is:
void SelectProc (cpick, client_data, allocated)
Widget cpick;
caddr_t client_data;
XColor *allocated;
The select, restore, and ok buttons call the appropriate callback
routine. The cancel button cancels any changes made to the initial
RGB values. The XtNchangeProc callback is called whenever the RGB
values change.
To destroy a Cpick widget instance, use XtDestroyWidget and specify
the widget ID for the Cpick.